package leetcode.greedy;

/**
 * @author mazouri
 * @create 2021-09-21 10:02
 */
public class _55_canJump {
    public boolean canJump(int[] nums) {
        int max = 0;

        if (nums.length == 1) return true;

        for (int i = 0; i < nums.length-1; i++) {
            max = Math.max(max,i+nums[i]);

            if (max>=nums.length-1) return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(new _55_canJump().canJump(new int[]{3,2,1,0,4}));
    }
}
